<?php
echo $javascript->codeBlock("
	$(document).ready(function(){
		copyDelivery($('#CustomerDeliveryAsBilling').attr('checked'));
		$('#CustomerDeliveryAsBilling').bind('change', function (event) {
			copyDelivery($(this).attr('checked'));
		});
	});
	
	function copyDelivery(checked){
		if(checked){
			$('#CustomerDeliveryName').attr('value',$('#CustomerName').attr('value'));
			$('#CustomerDeliverySurname').attr('value',$('#CustomerSurname').attr('value'));
			$('#CustomerDeliveryAddress1').attr('value',$('#CustomerAddress1').attr('value'));
			$('#CustomerDeliveryAddress2').attr('value',$('#CustomerAddress2').attr('value'));
			$('#CustomerDeliveryAddress3').attr('value',$('#CustomerAddress3').attr('value'));
			$('#CustomerDeliveryAddress4').attr('value',$('#CustomerAddress4').attr('value'));
			$('#CustomerDeliveryAddress5').attr('value',$('#CustomerAddress5').attr('value'));
		}else{
			$('#CustomerDeliveryName').attr('value','');
			$('#CustomerDeliverySurname').attr('value','');
			$('#CustomerDeliveryAddress1').attr('value','');
			$('#CustomerDeliveryAddress2').attr('value','');
			$('#CustomerDeliveryAddress3').attr('value','');
			$('#CustomerDeliveryAddress4').attr('value','');
			$('#CustomerDeliveryAddress5').attr('value','');
		}
		
	}
",$options = array('allowCache'=>false,'safe'=>false,'inline'=>false));
?>

<?php echo $this->Html->script(array('actions'),$options = array('allowCache'=>false,'safe'=>false,'inline'=>false));?>
<?php echo $this->Html->css(array('users.register','form','actions'),null,array('inline'=>false));?>

<div class="content">
	<div class="left-column">
		<div class="box corners">
		
			<div class="clr"></div>
		</div>
	</div>
		
	<div class="right-column">
		<div class="box corners">

			<table width="100%" style="padding-top:0px; margin: 0px;" cellpadding="0" cellspacing="0">
				<tr>
					<td colspan="2" align="left"><h2><?php echo __('Register',true)?></h2></td>
				</tr>
				<tr>
					<td align="left" valign="top" style="padding-top:0px; margin: 0px;" width="50%">
						<?php echo $this->Form->create('User',array('url'=>array('plugin'=>false,'controller'=>'users','action'=>'register')));?>
						<table cellpadding="0" cellspacing="0">
							<tr>
								<td align="left" valign="top" style="padding-top:0px; margin: 0px;">
									<h4><?php __("Contact"); ?></h4>
									<?php
										echo $this->Form->input('email',array('label'=>__("E-mail",true),'style'=>'width: 200px;','class'=>'wymagane'));
										
										echo $this->Form->input('password',array('label'=>__("Password",true),'style'=>'width: 200px;','class'=>'wymagane'));
										echo $this->Form->input('repeat_password',array('type'=>'password','label'=>__("Repeat password",true),'style'=>'width: 200px;','class'=>'wymagane'));	
										
	
										echo $this->Form->input('phone2',array('label'=>__("Phone",true),'style'=>'width: 200px;'));
											
// 										echo $this->Form->input('numer_referencyjny',array('label'=>__("Numer referencyjny",true),'after'=>__('Numer osoby która poleciła Ci nasz serwis.',true)));
										
	// 									echo $html->image('/captcha/captcha/image', array('escape'=>false));
	// 									echo $form->input('captcha', array('label' => false,'after'=>__('przepisz cyfry z obrazka',true)));
									?>
								</td>
		
								<td align="left" valign="top" style="padding-top:0px; margin: 0px;">
									<h4><?php __("Address"); ?></h4>
									<?php
										echo $this->Form->input('first_name',array('label'=>__("First Name",true),'style'=>'width: 200px;','class'=>'wymagane'));
										echo $this->Form->input('last_name',array('label'=>__("Last Name",true),'style'=>'width: 200px;','class'=>'wymagane'));
										echo $this->Form->input('address1',array('label'=>__("Address",true),'style'=>'width: 200px;'));
										echo $this->Form->input('address2',array('label'=>__("Address",true),'style'=>'width: 200px;'));
										echo $this->Form->input('address3',array('label'=>__("City",true),'style'=>'width: 200px;'));
										echo $this->Form->input('address4',array('label'=>__("Zip",true)));
										echo $this->Country->selectbox('User.delivery_address5');
									?>
								</td>
								<td align="left" valign="top" style="padding-top:0px; margin: 0px; display: none;">										
									<h4><?php __('Dane do dostawy'); ?></h4>
								 		<div class="input text required">
											<label for="CustomerDeliveryAsBilling"><?php echo __("Same as Billing Details?",true);?></label>
											<?php 
											echo $this->Form->checkbox('delivery_as_billing',array('hiddenField' => false)); 
											$this->Js->get('#CustomerDeliveryAsBilling');
											$this->Js->event( 'change', 'copyDelivery($("#CustomerDeliveryAsBilling").attr("checked"));' ,true);
											?>	
										</div>
									<?php									
										echo $this->Form->input('delivery_name',array('label'=>__("First Name",true),'class'=>'delivery_files','style'=>'width: 200px;'));
										echo $this->Form->input('delivery_surname',array('label'=>__("Surname",true),'class'=>'delivery_files','style'=>'width: 200px;'));
										echo $this->Form->input('delivery_address1',array('label'=>__("Address",true),'class'=>'delivery_files','style'=>'width: 200px;'));
										echo $this->Form->input('delivery_address2',array('label'=>__("Address",true),'class'=>'delivery_files','style'=>'width: 200px;'));
										echo $this->Form->input('delivery_address3',array('label'=>__("City",true),'class'=>'delivery_files','style'=>'width: 200px;'));
										echo $this->Form->input('delivery_address4',array('label'=>__("Zip Code",true),'class'=>'delivery_files','style'=>'width: 200px;'));
										echo $this->Country->selectbox('User.delivery_address5');
									?>
								</td>
							</tr>
						</table>
						
						<?php echo $this->Form->end(__('Submit',true));?>
					</td>
				</tr>
			</table>
			<div class="clr"></div>
		</div>
		<div class="clr"></div>
	</div>
	<div class="clr"></div>
</div>
<div class="clr"></div>